package demo.test.handler;

import com.just_bean.core.handler.AnnoHandler;
import com.just_bean.core.handler.JustMethodProxy;
import demo.test.anno.LogTs;

import java.lang.reflect.Method;

public class LogTsHandler extends AnnoHandler<LogTs> {
    @Override
    public JustMethodProxy method(Class<?> clz, Method method, LogTs a) throws Exception {
        String tag = a.tag();
        return new JustMethodProxy() {
            @Override
            public void pre(Method method, Class<?> clz, Object instance, Object[] args) throws Exception {
                System.out.println("before print tag:" + tag);
            }

            @Override
            public Object after(Method method, Class<?> clz, Object instance, Object[] args, Object result) throws Exception {
                System.out.println("after print tag:" + tag);
                return result;
            }
        };
    }
}
